﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Negocio.Clases_BL;
using Capa_Entidad;
public partial class Clinica_wfAdmisionBuscarPaciente : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnBuscar_Click(object sender, EventArgs e)
    {
        try
        {
            clsPacienteBLcs BL_Paciente = new clsPacienteBLcs();
            var consulta = from P in BL_Paciente.listar()
                           select new
                           {
                               P.PAC_CODIGO_PACIENTE,
                               P.PAC_NOMBRES,
                               P.PAC_APELLIDO_PATERNO,
                               P.PAC_APELLIDO_MATERNO
                           };

            dgBuscar.DataSource = consulta;
            dgBuscar.DataBind();


            //foreach (var prod in consulta)
            //{
            //    Console.WriteLine(prod.Name);
            //}

        }
        catch (Exception ex)
        {

            lblMensaje.Text = ex.Message;
        }
    }


  
    protected void btnAceptar_Click(object sender, EventArgs e)
    {
       // string cod=
        Session["codPaciente"] = dgBuscar.GetRowValues(dgBuscar.FocusedRowIndex, new String[] { "PAC_CODIGO_PACIENTE" }); 

      Response.Write("<script>window.opener.location = window.opener.location; </script>");
       //Response.Write("<script>window.opener.location.href = 'wfCita.aspx'; </script>");
       //window.opener.location.href="home.asp
       Response.Write("<script>self.close();</script>");
        //Response.Redirect("~/Clinica/wfCita.aspx?CodPaciente=" + dgBuscar.GetRowValues(dgBuscar.FocusedRowIndex, new String[] { "PAC_CODIGO_PACIENTE" }) + "");
     //  Response.Write("<script language=Javascript>window.close();return false;</script>");
        
               
        


    }
    protected void btnCancelar_Click(object sender, EventArgs e)
    {
        Session["codPaciente"] = "";
        Response.Write("<script>window.opener.location = window.opener.location; </script>");
        Response.Write("<script>self.close();</script>");
    }
}